﻿function AzureOnlineTableMarkersView(context) {

    var self = this;

    var markers = context.tables.markers;

    function reset() {
        context.tables.resetMarkers();
    }
    
    function save() {
        var settings = context.tables.tableSettings();
        var info = [];
        var list = markers();
        for (var i = 0; i < list.length; i++) {
            info.push(list[i].getInfo());
        }
        settings.setObject('markers', info);
    }

    self.markers = markers;
    self.save = save;
    self.reset = reset;
}

function AzureOnlineTableMarker() {

    var self = this;
    
    var color = ko.observable('none');

    var filterInput = new AzureTableFilterExpressionInput();
    
    var filter = filterInput.filter;

    function setInfo(info) {
        color(info.color);
        filter(info.filter);
    }

    function getInfo() {
        return {
            color: color(),
            filter: filter()
        };
    }

    self.color = color;
    self.filter = filter;
    self.expression = filterInput.expression;
    self.filterInput = filterInput;
    self.getInfo = getInfo;
    self.setInfo = setInfo;
}